// function sayHello(){
//     console.log("hello i'm gulp");
// }
// exports.sayHello = sayHello;


// let gulp = require("gulp");


// function styles(){
//     return gulp.src("./src/styles/index/*.css")
//             .pipe(gulp.dest("./dist/styles/"))
// }

// exports.styles = styles;
// 模块
let gulp = require("gulp");
let cleanCss = require("gulp-clean-css")
let rename = require("gulp-rename")
let concat = require("gulp-concat")
let babel = require("gulp-babel")
let uglify = require("gulp-uglify")
let devConfig = require("./gulp.dev")

//外置paths
let { paths }   = require("./gulp.config")

// console.log(process.argv[2]);
let type = process.argv[3] ? process.argv[3] : "dev";
//路径



//转存
function styles(){
    return gulp.src(paths.styles.src)
            // .pipe(concat("index.css"))   
            .pipe(cleanCss())
           
            // .pipe(rename())
           
            .pipe(gulp.dest(paths.styles.dist))
}

function scripts(){
    return gulp.src(paths.scripts.src)
            .pipe(concat("index.js"))
            .pipe(babel({
                presets : ['@babel/env']
            }))
            .pipe(uglify())
            .pipe(gulp.dest(paths.scripts.dist));
}

function html(){
    return gulp.src(paths.html.src)
    .pipe(gulp.dest(paths.html.dist))
  
}



//监听


// let build = gulp.series(styles,scripts);
// let build = gulp.series(useconnect , watch , gulp.parallel(styles , scripts ,html));
// let build = gulp.series(useconnect , watch );
// let build = gulp.series(gulp.parallel(useconnect , watch));



// return build;

//  指令
// exports.styles = styles;
// exports.watch = watch;
// exports.scripts = scripts;

// exports.html = html;





let build = gulp.series(html , styles , scripts);

exports.build = build;
exports.dev   = devConfig();